home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / abs_check.c next >
Encoding:
C/C++ Source or Header  |  1989-08-02  |  870 b   |  42 lines

  1. /*
  2.    abs_check: verify that the value has not changed more than the
  3.    allowed absolute amount.
  4.  
  5.    Kenneth Ingham
  6.  
  7.    Copyright (C) 1988 The University of New Mexico
  8. */
  9.  
  10. #include "defs.h"
  11. #include "y.tab.h"
  12.  
  13. abs_check(current, prev_val, allowable, cmd, name, line)
  14. char *current;
  15. double allowable;
  16. struct everything *prev_val;
  17. char *cmd, *name, *line;
  18. {
  19.     extern int line_ok;
  20.     double change, previous, value;
  21.     double to_double();
  22.  
  23.     previous = to_double(prev_val);
  24.     value = atof(current);
  25.  
  26.     change = value - previous;
  27.     if (change > allowable) {
  28.         if (line_ok) {
  29.             printf("%s had %s change by more than %.2f.\n",
  30.                 cmd, name, allowable);
  31.             printf("%s\n",line);
  32.         }
  33.         else {
  34.             printf("Also, it had %s change by more than %.2f.\n",
  35.                 name, allowable);
  36.         }
  37.         printf("Previous value %.2f; ",previous);
  38.         printf("current value %.2f.\n", value);
  39.         line_ok = False;
  40.     }
  41. }
  42.